package cn.rui.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.rui.pojo.vo.PageVo;
import cn.rui.common.ResponseBean;
import cn.rui.pojo.Notice;
import cn.rui.service.NoticeSerivice;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

/**
 * @author 徽州大都督
 * @date 2021/6/11
 */

@RestController
@RequestMapping("notice")
@Api(tags = "通知模块")
public class NoticeController {

    @Autowired
    private NoticeSerivice noticeSerivice;

    @PostMapping("findPage")
    @SaCheckLogin
    @ApiOperation(value = "分页查询通知列表")
    public ResponseBean findPage(@RequestBody PageVo pageVo, HttpSession session) {
        return noticeSerivice.findPage (pageVo,session);
    }

    @PostMapping("save")
    @SaCheckLogin
    @ApiOperation(value = "添加公告通知")
    public ResponseBean save(@RequestBody Notice notice, HttpSession session) {
        return noticeSerivice.save (notice,session);
    }

    @DeleteMapping("deleteById")
    @SaCheckLogin
    @ApiOperation(value = "根据ID删除通知")
    public ResponseBean deleteById(Integer id) {
        return noticeSerivice.deleteById (id);
    }
}
